﻿using B.S.AuthCenter.Api.Read.Application.Command.Menu;
using B.S.AuthCenter.Api.Read.Application.Command.MenuRole;
using B.S.AuthCenter.Api.Read.DTOs;
using B.S.AuthCenter.Api.Read.DTOs.RoleMenu;
using B.S.AuthCenter.ErrorCount;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.AuthCenter.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MenusController : ControllerBase
    {
        IMediator mediator;

        public MenusController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpGet]
        public Task<ApiResult<List<MenuParentDTO>>> GetMenuParment([FromQuery]GetMenuParentCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<List<MenuParentDTO>>> GetTreeMenu([FromQuery]GetMenuTreeCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<List<RoleMenuDTO>>> GetRoleMenu([FromQuery]GetRoleMenuCommand request)
        {
            return mediator.Send(request);
        }
    }
}
